<?php

/**
 * CelebrioGallery
 *
 * @copyright  Copyright (c) 2011 Celebrio Software
 * @package    CelebrioPeople
 */

namespace ApplicationsModule\ApplicationModule;

use \Nette\Object;
use Celebrio\AccessControl\UserManagement;
use Nette\Environment;
use Celebrio\Core\IModuleInit;
use Celebrio\Core\DummyInit;
use Celebrio\Modules;
use KernelModule\AclModule\AclManagement;
use KernelModule\ApplicationsModule\AppManagement;
use Albireo\Application\Application;

/**
 * Gallery module initialization. Makes basic Gallery folder and first gallery
 * named _("Default") and saves folder image for empty galleries.
 * 
 * @author honza
 */
class ApplicationInit extends DummyInit implements IModuleInit {

    private $aclManagement;
    private $appManagement;

    public function __construct() {
        $this->aclManagement = new AclManagement();
        $this->appManagement = new AppManagement(Environment::getUser());
    }

    public function install(array $configuration) {
        parent::install($configuration);
        $uri = Environment::getHttpRequest()->getUri();
        $base = $uri->scheme . "://" . $uri->host . ":" . $uri->port . $uri->scriptPath . 'app/';
        $this->aclManagement->addOneRule("admin", "Kernel:Applications:Management", "default", TRUE, null);
        $this->aclManagement->addOneRule("admin", "Kernel:Applications:Management", "add", TRUE, null);
        $this->aclManagement->addOneRule("admin", "Kernel:Applications:Management", "edit", TRUE, null);
        $this->aclManagement->addOneRule("admin", "Kernel:Applications:Management", "delete", TRUE, null);

        $app = new Application("Weather", $base . "weather");
        $app->setPublisher("Celebrio");
        $app->setAltText("Weather forecast for your location");
        $app->setAuto(true);
        $app->setSystem(true);
        $app->setVersion(0.9);
        $app->setTranslations(array(
            "cs" => "Počasí",
            "en" => "Weather",
            "sk" => "Počasie"
        ));

        $this->appManagement->addApplication($app);

        $app = new Application("E-mail", $base . "mail");
        $app->setPublisher("Celebrio");
        $app->setAltText("E-mail application");
        $app->setAuto(true);
        $app->setSystem(true);
        $app->setVersion(0.6);
        $app->setTranslations(array(
            "cs" => "Pošta",
            "en" => "E-mail",
            "sk" => "Pošta"
        ));
        $this->appManagement->addApplication($app);

        $app = new Application("Talker", $base . "talker");
        $app->setPublisher("Celebrio");
        $app->setAltText("Communication");
        $app->setAuto(true);
        $app->setSystem(true);
        $app->setVersion(0.4);
        $app->setTranslations(array(
            "cs" => "Kecálek",
            "en" => "Talker",
            "sk" => "Kecálek"
        ));
        $this->appManagement->addApplication($app);

        $app = new Application("People", $base . "people");
        $app->setPublisher("Celebrio");
        $app->setAltText("People");
        $app->setAuto(true);
        $app->setSystem(true);
        $app->setVersion(0.5);
        $app->setTranslations(array(
            "cs" => "Lidé",
            "en" => "People",
            "sk" => "Ľudia"
        ));
        $this->appManagement->addApplication($app);

        $app = new Application("Gallery", $base . "gallery");
        $app->setPublisher("Celebrio");
        $app->setAltText("Photos");
        $app->setAuto(true);
        $app->setSystem(true);
        $app->setVersion(0.7);
        $app->setTranslations(array(
            "cs" => "Fotografie",
            "en" => "Gallery",
            "sk" => "Fotografie"
        ));
        $this->appManagement->addApplication($app);

        $app = new Application("News", $base . "news");
        $app->setPublisher("Celebrio");
        $app->setAltText("News");
        $app->setAuto(true);
        $app->setSystem(true);
        $app->setVersion(0.7);
        $app->setTranslations(array(
            "cs" => "Zprávy",
            "en" => "News",
            "sk" => "Správy"
        ));
        $this->appManagement->addApplication($app);

        $app = new Application("TV", $base . "television");
        $app->setPublisher("Celebrio");
        $app->setAltText("TV");
        $app->setAuto(true);
        $app->setSystem(true);
        $app->setVersion(0.7);
        $app->setTranslations(array(
            "cs" => "Televize",
            "en" => "TV",
            "sk" => "Televízia"
        ));
        $this->appManagement->addApplication($app);

        $app = new Application("Application", $base . "application");
        $app->setPublisher("Celebrio");
        $app->setAltText("App management");
        $app->setAuto(true);
        $app->setSystem(true);
        $app->setVersion(0.8);
        $app->setTranslations(array(
            "cs" => "Aplikace",
            "en" => "Applications",
            "sk" => "Aplikácie"
        ));
        $this->appManagement->addApplication($app);

        $app = new Application("Preferences", $base . "preferences");
        $app->setPublisher("Celebrio");
        $app->setAltText("Preferences");
        $app->setAuto(true);
        $app->setSystem(true);
        $app->setVersion(0.2);
        $app->setTranslations(array(
            "cs" => "Nastavení",
            "en" => "Preferences",
            "sk" => "Nastavenie"
        ));
        $this->appManagement->addApplication($app);
    }

}